

class Creep:
    def __init__(self, alive = 1, HP = 10, instance):
        self.life = alive            #1 is alive, 0 is dead
        self.health = HP
        self.instance = instance
        self.x = x.Path(instance)           #has something to do with where 
        self.y = y.Path(instance)           #the front creep is on the path.
        
    def __str__(self):
        print 'Who are you?', instance, ". Alive?", life, "HP:" health,
        '. Where are you? (', positionx, position y, ').'

    def update(self, instance):
        self.x = x.Path(instance)           #has something to do with where 
        self.y = y.Path(instance)           #the front creep is on the path.
        
    def losehealth(self, damage):
        self.health = self.health - damage
        if self.health <= 0:
            self.die()

    def die(self):
        self.life = 0
    

class Tower:
    __init__(self, s, y, towertype):
        
    position
    angle
    upgrade
    
    def targetcreep(self):
        
        

class LaserTower:

class WindTower:

class BombTower:

etc.
    

class Killswitch:
    __init__(self, x, y):
        self.state = 0          #Not sure if this is necessary.
        self.x = x
        self.y = y
        
    __str__(self):
        print "I am here: (", self.x, self.y ") and I am ", self.state

    def kill(self):
        self.state = 1
        #vendor request goes here.
        self.state = 0

class CreepPath:
    def __init__(self):
        gear_pos = [(c1x, c1y, r1), (c2x, c2y, r2), etc)
        delimeters(gear_pos)

    def delimeters(self, gear_pos):
        d=[(0, 0, 0)]
        dist = 0
        (tlast, tfirst, garbage) = cctangent(gear_pos[-1], gear_pos[0])
        for ngear in range(len(gear_pos)-1):
            (t1, t2, ini_angle) = cctangent(ngear, ngear+1)

            arc = tfirst[1]
            dist += arc
            d[2*ngear-1] = (dist, t1[0], t1[1], ini_angle, ngear[2])

            dist += math.sqrt((t2[1] - t1[1])**2 + (t2[0] - t1[0])**2)
            d[2*ngear] = (dist, t2[0], t2[1])
                                             
                       #total distance, x, y, angle for gears, radius
        self.delimeters = d


def cctangent(c1, c2):
    th_ini = math.atan2(c2.y-c1.y,c2.x-c1.x)
    l = math.sqrt((c2.y-c1.y)**2 + (c2x-c1.x)**2)
    th = math.acos((c1.r-c2.r)/l)
    t1x = c1x + r1 * math.cos(th+th_ini)
    t1y = c1y + r1 * math.sin(th+th_ini) 
    t2x = c2x + r2 * math.cos(th+th_ini)
    t2y = c2y + r2 * math.sin(th+th_ini)
    return (t1x, t1y, t2x, t2y)

    def get_xy_pos(self, time, dist_behind):
#        d = self.rate*time - dist_behind
        d = 1
        for i in range(len(self.delimters)):
            #delimeters in the form [(d1, x1, y1, th_ini, r), (d2, x2, y2)]
            #bool = 1: theta increasing; -1: theta decreasing
            p1 = delimeters[i]
            p2 = delimeters[i+1]
            if d >= delimeters[-1][0]:      #The front creep has done a lap
                return(x, y) 
                self.y = 
            if delimeters[i][0] < d < delimeters[i+1][0]:
                if i % 2 == 0:      #Even sections are linear
                    x = d / (p2[0] - p1[0]) * (p2[1] - p1[1])
                    y = d / (p2[0] - p1[0]) * (p2[2] - p1[2])
                    
                else:               #Odd sections are turns
                    x = p1[1] + math.cos(p1[3] + p1[5]*(d - p1[0])/p1[4])
                    y = p1[1] + math.sin(p1[3] + p1[5]*(d - p1[0])/p1[4])


    def updatecreeps(creeps, time):
        for creep in creeps:
            creep.setxy( get_xy_pos(time, creep[1]) )
    rate
    front creep position
    function describing path

class Board:
    all tower positions
    list of creeps

    def update(self):

update
how long since last update?
where was the creep last time?
what is the new position on the path
